home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / osrc.arc / TCPTIMER.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-31  |  1022 b   |  44 lines

  1. /* TCP timeout routines */
  2. #include <stdio.h>
  3. #include "global.h"
  4. #include "mbuf.h"
  5. #include "timer.h"
  6. #include "netuser.h"
  7. #include "internet.h"
  8. #include "tcp.h"
  9.  
  10. /* Timer timeout */
  11. void
  12. tcp_timeout(tcb)
  13. register struct tcb *tcb;
  14. {
  15.     if(tcb == NULLTCB)
  16.         return;
  17.  
  18.     /* Make sure the timer has stopped (we might have been kicked) */
  19.     stop_timer(&tcb->timer);
  20.  
  21.     switch(tcb->state){
  22.     case TIME_WAIT:        /* 2MSL timer has expired */
  23.         close_self(tcb,NORMAL);
  24.         break;
  25.     default:        /* Retransmission timer has expired */
  26.         tcb->flags.retran = 1;    /* Indicate > 1  transmission */
  27.         tcb->backoff++;
  28.         tcb->snd.ptr = tcb->snd.una;
  29.         /* Reduce slowstart threshold to half current window */
  30.         tcb->ssthresh = tcb->cwind / 2;
  31.         tcb->ssthresh = max(tcb->ssthresh,tcb->mss);
  32.         /* Shrink congestion window to 1 packet */
  33.         tcb->cwind = tcb->mss;
  34.         tcp_output(tcb);
  35.     }
  36. }
  37. /* Backoff function - the subject of much research */
  38. backoff(n)
  39. int n;
  40. {
  41.     return 1 << n;    /* Binary exponential back off */
  42. }
  43.  
  44.